home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
WINDOWS
/
WBB11.ARJ
/
BB.DOC
next >
Wrap
Text File
|
1992-05-15
|
61KB
|
2,509 lines
BasicBasic is copyright (c) 1992 by Mark Davidsaver. All
rights reserved.
ORDER INFORMATION
-------------------------------------------------------
If you find BasicBasic useful registration is requested.
Through August 31, 1992, the registration fee is $15.00.
After that date the fee is $30.00. Registration includes
one free upgrade to the software and documentation.
Please state the version of the software that you
currently have and whether 3 1/2 or 5 1/4 diskettes are
needed. Illinois residents add 6.25% sales tax.
Send check or money order to: Mark Davidsaver
213 S. Park Street
Bishop Hill, Il 61419
or phone with MC/Visa orders to: (309) 927-3303
BasicBasic is copyright (c) 1992 by Mark Davidsaver
TABLE OF CONTENTS
Summary ................................ 2
Getting Started Quickly ................ 3
BasicBasic Basics ...................... 5
Windows Metacommands ................... 7
Metacommands ........................... 8
Statement and Function Reference ....... 9
Windows and Fonts ...................... 25
(386 Enhanced Mode Font information)
Programming Buttons .................... 27
Programming Menus ...................... 29
Communications Programming ............. 31
Chaining and Common .................... 32
Errors ................................. 33
Keyboard codes ......................... 35
1
BasicBasic is copyright (c) 1992 by Mark Davidsaver
SUMMARY
-------------------------------------------------------
BasicBasic is an easy to program, Basic-like language for
DOS or Windows. BasicBasic contains a subset of Microsoft
Basic as well as many new commands unique to BasicBasic.
BasicBasic is an easy way to develop small to medium size
programs without regard for which environment they will
run under. BasicBasic supports mouse and buttons in both
DOS and Windows and Menus in Windows. Several commands
from more advanced Basics are also included (such as the
DIR$ function and binary file I/O from Microsoft
Professional Basic). Programs written for BasicBasic can
run under either DOS or Windows. The compiler, itself,
may run under either DOS or Windows.
In addition to BasicBasic you will need a source editor
for the environment you are running under. BasicBasic
accepts source from standard ASCII files.
Here is a list of statements and functions the BasicBasic
compiler recognizes. Refer to the detailed description
later on for the exact syntax recognized.
ABS ADDSUBMENU ASC BEEP CBUTTON CHAIN CHR$
CLOSE CLS COLOR COMMON COMSTATI CSRLIN DATA
DATE$ DBUTTON DIM DIR$ EOF FIELD FIX
FOR..NEXT FREEMEM GET # GOSUB..RETURN GOTO
IF..THEN..ELSE INKEY$ INPUT INPUT # INPUT$ INSTR
INT KILL LEFT$ LEN LET LINE INPUT # LOC
LOCATE LSET MAINMENU MENUITEMGRAY MENUITEMON
MID$ MKDIR MOUSEB MOUSEON MOUSEX MOUSEY OPEN
OPEN "COMn:" POS PRINT PRINT # LPRINT PRINT
USING PUT # LPRINT USING OSTYPE RADIOON RADIOOFF
READ REM RESTORE RETURN RIGHT$ RMDIR RND
SCROLLAREA SETERRLEVEL SPACE$ STOP STR$ STRING$
TAB TIME$ TIMER UCASE$ VAL WRITE #
and the operators + - / * \ ^ AND OR
2
BasicBasic is copyright (c) 1992 by Mark Davidsaver
GETTING STARTED QUICKLY
-------------------------------------------------------
The easiest way to run BasicBasic is to have all required
files in one directory. If you are not going to be
running or compiling under either DOS or Windows you do
not need the files specific to them. BasicBasic files
required for each operating environment are:
FILE USE
_____ __________________________________
BB.EXE \_ required to compile under DOS
BB11.STB /
BBLIB11.EXE _ runtime required to run application
under DOS
WBB.EXE \_ required to compile under Windows
BB11.STB /
WBBLIB11.EXE _ runtime required to run application
under Windows
You may also want the provided sample programs.
(SAMPLE1.BAS, SAMPLE2.BAS, etc.)
Before compiling a program you must have the Source in an
ASCII file. Most word processors have an option to allow
reading/writing of ASCII files. Windows Write, for
example, allows you to save in Text Only format which is
ASCII. When opening ASCII files you must be sure to tell
Write to NOT convert file to Write format.
Several sample programs are provided to let you get
started quickly. These are named SAMPLE1.BAS,
SAMPLE2.BAS, etc.
To compile a program under DOS type BB. When requested
enter the file name you want to compile. If no extension
is given the compiler will assume .BAS. You can also
enter the file name you want to compile as part of the
start command. e.g. BB SAMPLE1.BAS. The executable
file created will have the same name as the source file.
Under Windows you must compile using the program WBB.EXE.
You may install this in a group with the Program Manager
or run WBB seperately. When compile is completed you may
either execute the program or restart to compile another
program.
IMPORTANT! Whether you are compiling under DOS or Windows
3
BasicBasic is copyright (c) 1992 by Mark Davidsaver
only one EXE file will be created. This file will have
the same name as the source file with an extenstion of
.EXE. This EXE file can be executed under either DOS or
Windows as long as the appropriate runtime module is
present (BBLIB11.EXE for DOS or WBBLIB11.EXE for Windows).
DOS programs require the presence of BBLIB11.EXE to run
and Windows programs require the presence of WBBLIB11.EXE
to run. If this runtime library file is not found an
error message will be returned (In Windows the absence of
WBBLIB11.EXE is indicated by 4 short beeps and the program
does not execute).
If you are running Windows 3.1 in 386 Enhanced Mode see
the section on Windows and Fonts for important information
on using different font sizes.
4
BasicBasic is copyright (c) 1992 by Mark Davidsaver
BasicBasic Basics
-------------------------------------------------------
BasicBasic is intended to be a subset of Microsoft Basic.
More statements and functions will be added with each
release. Depending on your religion you may or may not be
happy to see that GOTO is supported. BasicBasic's syntax
is 'almost' the same as Microsoft's Basic. Here are some
known syntax differences:
BasicBasic scans expressions from left to right the
same as Microsoft Basic, however, BasicBasic checks
all multiplies before divides and all minus signs
before addition.
BasicBasic does not support the underscore (_) line
extension character.
Most functions and statements have the same syntax as
Microsoft Basic. You should check the Statement and
Function Reference section for details on syntax for the
following commands/functions which may differ from
Microsoft Basic or which are unique to BasicBasic.
CLOSE CLS COLOR COMMON DIR$ FREEMEM GET #
INPUT$
LOCATE LPRINT USING OPEN PRINT USING
PUT # RETURN RND SETCOM SETERRLEVEL STRING$
Double precision numbers are not supported in this
version.
BasicBasic does not support a standard array of size 10.
Every array must be explicitly dimensioned with a DIM
statement.
CAPACITIES
Maximum number of arrays: 100
Total open files: 10
Total string space: approximately 47000 chars.
Maximum character string size: 2048
Maximum Buttons: 40
Maximum menus: 6
Maximum Items in a menu: 10
RESERVED WORDS
All names of statements and functions are reserved words
and may not be used as variable names. ERR is a special
case. This is a system wide variable used to return error
5
BasicBasic is copyright (c) 1992 by Mark Davidsaver
information to BasicBasic programs. See the command
SETERRLEVEL for more complete information.
6
BasicBasic is copyright (c) 1992 by Mark Davidsaver
WINDOWS METACOMMANDS
-------------------------------------------------------
BasicBasic contains several Metacommands to set Windows
environment parameters. These commands have no affect on
execution of the program. All Windows Metacommands have
the following format:
REM WINDOWS command
REM WINDOWS NAME name
The window name which the program will display can be
supplied. The default is the same as the file name of the
program.
e.g. REM WINDOWS NAME investments
REM WINDOWS size x1,y1,x2,y2
This command allows you to define a portion of the normal
DOS screen size as the area to be displayed in the Windows
window. This is useful if you have a program centered in
the standard 80x25 DOS screen, but do not use much of the
border area. Regular scrolling may not work in windows if
you define the window size as less than 80x25. X1 is the
left column, y1 is the top row, x2 is the right column,
and y2 is the bottom row. e.g.
e.g. REM WINDOWS SIZE 10,10,70,15
7
BasicBasic is copyright (c) 1992 by Mark Davidsaver
METACOMMANDS
-------------------------------------------------------
metacommands are preceded by REM and a dollar sign.
INCLUDE:
This metacommand allows you to include source from
another file in the currently compiling file. files may
be nexted up to 10 levels deep.
e.g. REM $INCLUDE: moretext.asc
8
BasicBasic is copyright (c) 1992 by Mark Davidsaver
STATEMENT AND FUNCTION REFERENCE
-------------------------------------------------------
Here is a brief description of available functions and
statements. More detailed information on those not unique
to BasicBasic can be found in standard Basic reference
books.
ABS(numericexpression)
This function returns the absolute value of the numeric
expression.
ADDSUBMENU menunumber,stringexpression,keycode
This command is ignored in DOS. Addsubmenu adds an item
to a pull down menu with the text stringexpression.
When the user selects this menu item the keycode will be
returned at the next INKEY$ function call. See the
section 'Programming Menus' for more details
ASC(string expression)
This function returns a numerical value which is the
ASCII code for the first character of string expression.
BEEP
This statement sounds the ASCII bell character.
CBUTTON "name",keycode,0,"type",0,left,top,xsize,ysize,
forecolor,backcolor
This command defines and creates a button on screen.
This command is DOS and Windows compatible. The name is
the text which will be displayed in the button. When
you define a button you must define the keycode which
will be returned when that button is pressed by the
user. Legal button types are "Radio", "Push" or
"Invisible". Left, top, xsize, ysize define the
position and size of the button(in character position).
Radio buttons may have a foreground and background color
defined. If these are left 0 then the default colors
9
BasicBasic is copyright (c) 1992 by Mark Davidsaver
will be used. In DOS the colors are also used for
Pushbuttons.
When the user presses the button the indicated keycode
will be returned to the INKEY$ function. If a button is
pressed while executing the INPUT command the input will
be ended, but the keycode will not be returned until a
subsequent INKEY$ function is called. Instead of using
the mouse to press the indicated button, the user can
also press the keyboard key which returns the indicated
keycode.
Any key may be defined for a button. See the section
"Keyboard codes" for a list of codes recognized by
BasicBasic. As an example the uppercase letter 'A'
would be the keycode 65. Extended keycodes are
indicated by adding 1000 to the second part of the code.
For example F1 would be 1059, or F10 would be 1068.
e.g. CBUTTON "Exit",1068,"Push",0,1,1,8,1,7,4
Creates a push button on the top line. Because
it is a Push button the color values are ignored
in windows, but used in DOS.
See RADIOON and RADIOOFF for instructions on
checking/unchecking radio buttons.
See the section "Programming Buttons" for more detail on
programming buttons.
Note that while CBUTTON creates a button it will not
respond to the mouse button until the function MOUSEON
has been issued.
CHAIN filespec
This command transfers control from the current program
to another program. COMMON may be used to pass
variables between programs. Files are left open when
transfering to another program. See the section
'Chaining and Common' for more details.
e.g. CHAIN "TEST2.EXE"
CHR$(numeric expression)
This function returns the ASCII code for the numeric
expression. The returned code is one character.
10
BasicBasic is copyright (c) 1992 by Mark Davidsaver
CLOSE #filenumber
This statement terminates I/O to the indicated
filenumber. Only one number allowed for each CLOSE
command.
CLS
This statement clears the screen. If a scrollable area
has been define the entire screen is still cleared.
COLOR foreground,background
This statement sets the screen colors to the indicated
foreground and background colors. Color values are:
0 - Black
1 - Blue
2 - Green
3 - Cyan
4 - Red
5 - Magenta
6 - Brown
7 - White
8 - Gray
9 - Light Blue
10 - LIght Green
11 - Light Cyan
12 - Light Red
13 - Light Magenta
14 - Yellow
15 - High intensity white
Foreground values can be 0 through 7 and background
values can be 0 through 15.
COMMON variablelist
Common passes variables to a chained program.
Variablelist is a list of variables and arrays whose
contents will be preserved when Chaining to a new
program. Only 'blank' common is supported. A blockname
is not allowed. the SHARED attribute is not allowed.
Arrays are indicated by blank parenthesis. See the
section 'Chaining and Common' for more details.
11
BasicBasic is copyright (c) 1992 by Mark Davidsaver
e.g. COMMON A,B,A$,B$()
COMSTATI(comnum)
This function returns the status of a communications
port. 8 bits of data are returned. These are defined
as follows:
bit 7 = Data Carrier Detect
6 = Ring Indicator
5 - Data Set Ready
4 - Clear to Sent
3 - Break Detect
2 - Framing Error
1 - Parity Error
0 - Overrun Error
e.g. a=COMSTATI(1)
CSRLIN
This function gets the current line position of the
cursor.
DATA
This statement is used in conjuction with the READ
statement to input numeric or string constants.
DATE$
This function returns a string of ten characters
corresponding to the current computer date.
DBUTTON keycode
This statement erases a button from the screen (using
currently define colors) and disables input from it.
The keycode should be the same as that used in the
CBUTTON command. See the section "Programming Buttons"
for more information on buttons.
12
BasicBasic is copyright (c) 1992 by Mark Davidsaver
DIM variable(subscripts),...
Defines arrays. There is no default array size of 10 in
BasicBasic. Every array must be defined. SHARED is not
supported.
DIR$(path,[type])
or
DIR$
This function returns file names. If no type is
specified or type is set to 0 then file names not
including system and hidden will be returned. If no
path is specified then the next name using the previous
search path will be returned. Type may be set to a
non-zero value to return the names of special classes of
files.
type file type
1 Read Only files
2 Hidden files
3 System files
5 Directories
6 Archive bit set
EOF(filenumber)
This function tests for end-of-file.
FIELD #filenumber,fieldwidth AS stringvariable...
This statement allocates space for variables in
random-access file buffer. The filenumber is the number
under which the file was opened. Fieldwidth is a number
indicating the length of the field and string variable
is the name of the field. Multiple fields can be
defined at once.
e.g. OPEN "TEST.DAT" FOR RANDOM AS #1
FIELD #1,18 AS NAME$,18 AS ADDRESS$
LSET NAME$="FRED SMITH"
LSET ADDRESS$="1 MAIN STREET"
PUT #1,1
CLOSE #1
FIX(numeric expression)
13
BasicBasic is copyright (c) 1992 by Mark Davidsaver
This function returns the integer representation of the
value in numeric expression. -n.x returns n-1 if x>0.
FOR..NEXT
FOR counter=start TO end [STEP increment]
Defines a program loop.
FREEMEM
This function returns the amount of global memory
available to other programs.
GET #filenumber,recordnumber,variable$
This statement allows input of data from BINARY files.
Recordnumber is an absolute byte position in the file.
The first byte of the file is number 1.
GOSUB label
This statement causes a branch to a subroutine.
GOTO label
This statement causes a jump to another program
location.
IF...THEN...ELSE
Permits conditional execution depending on evaluation of
expression.
INKEY$
This function returns a character from the keyboard.
14
BasicBasic is copyright (c) 1992 by Mark Davidsaver
INPUT[;]["promptstring"{;|,}] variablelist
Executing this statement causes the program to pause and
wait for input. A promptstring may optionally be
printed before pausing for input. If a comma is used
after the promptstring or if no prompt string is
specified a question mark is displayed before waiting
for input. If INPUT is followed by a semicolon, then no
carriage return line feed is performed after the Enter
key is pressed.
INPUT #filenumber,variablelist
This statement reads items from an open file to the
given variables. When inputting data leading spaces
will be ignored.
INPUT$(n,port)
This function returns a string of n characters from a
communications port. If n characters are not available
the function will WAIT for that many characters to
arrive. To avail 'hanging up' your program use the LOC
function to find how many characters are waiting. If a
communications error occurs the number of characters
returned may be less than what you requested. In this
case use the function COMSTATI to determine what error
occured. See the section "Communications Programming"
for more details.
INSTR([start],expressiontosearch,searchforexpression)
This function searches for the first occurence of
searchforexpression in expressiontosearch and returns
the position at which the match is found. If no match
is found then 0 is returned.
INT(numericexpression)
This function returns the largest integer less than or
equal to numericexpression.
KILL stringexpression
15
BasicBasic is copyright (c) 1992 by Mark Davidsaver
This command deletes the file whose name is in
stringexpression.
LEFT$(stringexpression,n)
This function returns a string of length n from the left
part of stringexpression
LEN(stringexpression)
This function returns the number of characters in
stringexpression.
LET
May optionally be used before assignment statements.
e.g. LET I=3
LINE INPUT #,filenumber,stringvariable
This statement inputs an entire line from a file. Input
continues until the next carriage return.
LOC(filenumber)
This function returns the current absolute byte position
within a file. For a communications port it returns the
number of received characters waiting in the receive
buffer.
LOCATE row,column,[cursor]
Positions the cursor on the screen. If cursor is set to
0 then the cursor is turned off.
LPRINT expressionlist [,|;]
Prints the items in expression list. See PRINT for a
more complete description.
16
BasicBasic is copyright (c) 1992 by Mark Davidsaver
LPRINT USING formatstring; expressionlist[,|;]
The formatstring tells how to print the items in
expressionlist. See PRINT USING for a description of
format string items.
LSET stringvariable=string expression
This command puts data into a random access file buffer.
The buffer must be previously defined by a FIELD
statement. The data is left justified in the field.
e.g. OPEN "TEST.DAT" FOR RANDOM AS #1
FIELD #1,18 AS NAME$,18 AS ADDRESS$
LSET NAME$="FRED SMITH"
LSET ADDRESS$="1 MAIN STRING"
PUT #1,4
CLOSE #1
MAINMENU stringexpression,stringexpression...
This command is ignored in DOS. This command defines
the main menu bar for Windows. Up to six sub menu names
may be specified. If less than six are defined, blank
strings must be present. See the section 'Programming
menus' for more detail.
e.g. MAINMENU "File","Color","Options","","",""
MENUITEMGRAY keycode
This command is ignored in DOS. This command 'grays' a
submenu item. While gray the item cannot be selected by
the user. See the section 'Programming menus' for more
detail.
MENUITEMON keycode
This command is ignored in DOS. This command enables a
submenu item. When enable a user may select this menu
item.
17
BasicBasic is copyright (c) 1992 by Mark Davidsaver
MID$(stringexpression,n,length)
This function returns a string composed of length
characters starting with character n in
stringexpression.
MKDIR stringexpression
This command creates a directory specified by
stringexpression
MOUSEB
This function returns information on whether mouse
buttons are pressed. Bit 0 is 1 if left button is
pressed. Bit 1 is 1 if right button is pressed. Bit 2
is 1 if middle button is pressed.
e.g. b=mouseb
b=b and 2
if b<>0 then
print "right button is pressed."
end if
MOUSEON
This function intializes the mouse. It returns a -1
(true) if a mouse is present. It returns 0 if no mouse
is present. This function must be issued before the
mouse can be used in both DOS and Windows.
e.g. mouseflag=mouseon
MOUSEX
This function returns the x position of the mouse in
character units (1 through 80).
e.g. x=mousex
MOUSEY
This function returns the y position of the mouse in
18
BasicBasic is copyright (c) 1992 by Mark Davidsaver
character units (1 through 25).
e.g. y=mousey
OPEN filename FOR access AS #
This command prepares the file filename for access as
number #. Access types supported are INPUT, OUTPUT,
APPEND, BINARY, RANDOM. This is the only syntax form
supported by BasicBasic
e.g. OPEN "TEST.DAT" FOR INPUT AS #1
OPEN "COMn: speed,parity,data,stop" FOR RANDOM AS #n LEN=n
This statement opens and initializes a communications
port. COM1 and COM2 are supported. Supported speeds
are 9600, 4800,2400,1200,and 300. Parity may be either
E,O,N, or M. Data may be either 5,6,7, or 8. Stop may
be either 1, 1.5, or 2. LEN is used to specify the size
of the input buffer. The default is 128 bytes. For
Windows programs a minimum of 2048 is suggested.
Only PRINT # will output characters to an open
communications port. Only INPUT$ will receive
characters from a port.
Communications parameters may be omitted; however, their
position must be marked by commas. Default parameters
are 300 baud, No parity, 8 data bits, and 1 stop bit.
e.g. OPEN "COM1: 2400,E,7,1" for random as #1 len=2048
See the section "Communications Programming" for more
details.
OSTYPE
This function returns a number indicating what operating
system the program is running under.
1 - DOS
2 - Windows 3.x
3 - ?
19
BasicBasic is copyright (c) 1992 by Mark Davidsaver
POS(0)
This function returns the current column position of the
cursor.
PRINT expressionlist [,|;]
Prints the items in expression list. PRINT with no
expression results in a blank line being printed. If
the expression is followed by a semi-colon (;) the next
print starts immediately following this one. If the
expression ends in a comma (,) the next print starts at
the next print position. Print positions are at columns
1, 15, 29, etc.
PRINT USING formatstring; expressionlist[,|;]
The formatstring tells how to print the items in
expressionlist. Any text may be in formatstring.
BasicBasic only recognizes three format characters.
These are pound sign (#) comma (,) and period (.).
Each time a number character is found (#) one item from
the expression list will be printed.
e.g. PRINT USING "The answer is: ###,###.##";number
PRINT #filenumber,expressonlist
Prints to a file or communications port the items in
expression list.
PUT #filenumber,recordnumber,stringexpression
PUT #filenumber,recordnumber
This statement is used to output data to a file opened
in either BINARY or RANDOM mode.
In BINARY mode the string expression will be written to
the file at the byte location given by recordnumber.
Recordnumber is the absolute byte number to be written,
where the first byte of the file is 1.
e.g. A$=SPACE$(20)
PUT #1,100,A$ (writes 20 bytes starting at 100)
20
BasicBasic is copyright (c) 1992 by Mark Davidsaver
In RANDOM mode the data in the output buffer will be
written to the record number indicated.
e.g. PUT #1,1 (writes to record 1)
RADIOON keycode
This command 'checks' the indicated Radio button. See
the section "Programming Buttons" for more information.
RADIOOFF keycode
This command 'unchecks' the indicated Radio button. See
the section "Programming Buttons" for more information.
READ variablelist
Inputs a value from a DATA statement.
REM
Denotes a comment line and is ignored by the compiler.
RESTORE label
Sets position that next READ statement will input data
from.
RETURN
Returns program execution to location immediately after
last GOSUB.
RIGHT$(stringexpression,n)
This function returns a string of length n from the
right part of stringexpression
21
BasicBasic is copyright (c) 1992 by Mark Davidsaver
RMDIR stringexpression
This command removes the directory given by
stringexpression.
RND
This function returns one in a sequence of random
numbers between 0 and 1.
SCROLLAREA leftx,topy,rightx,bottomy
This statement defines an area of the screen which is
used for scrolling. This allows you to create fixed
text or buttons in one area of the screen while
scrolling another area. Leftx, topy, rightx, bottomy
are in character units and are inclusive.
Executing the CLS command will clear the entire screen,
not just the scrollable area. PRINT CHR$(12); will only
clear the scrollable area.
SETCOM comnum,"Speed,Parity,Databits,Stopbits,dtr,rts"
This statement allows you to change communications
parameters for an already opened communications port.
Speed, Parity, Databits, and Stopbits are described in
OPEN COM. DTR may be either ON or OFF. If ON then the
output data terminal ready signal will be set high. ON
is the default. RTS may be either 1 or 0. If 1 then
the output request to send is high. 1 is the default.
Communications parameters not present will not be
changed; however, a comma must mark their positions.
e.g. SETCOM 1,",,7"
Sets number of data bits to 7.
e.g. SETCOM 1,",,,,OFF"
Turns Data terminal read;y off.
See the section "Communications Programming" for more
information.
SETERRLEVEL level
22
BasicBasic is copyright (c) 1992 by Mark Davidsaver
This command defines what BasicBasic should do in case
of runtime errors. Level must be a number (not an
expression or variable). Level 7 causes execution to
halted for all errors. Level 5 causes execution to
continue for recoverable errors. In the latter case the
global variable ERR is set to the error number. ERR may
be reset with the statement: ERR=0. ERR will be reset
each time an error occurs so the program must check ERR
immediately after statements which may produce errors.
SPACE$(N)
Returns a string of n spaces.
STOP
Causes the program to cease execution.
STR$(numericexpression)
This function returns a string representation of the
numbericexpression.
STRING$(m,stringexpression)
This function returns a string of length n. This string
is composed of the first character in stringexpression.
TAB(numericexpression)
In PRINT or LPRINT statements positions output at column
position given in numericexpression.
TIME$
This function returns a string representation of the
current system time.
TIMER
23
BasicBasic is copyright (c) 1992 by Mark Davidsaver
This function returns the number of seconds since
midnight.
UCASE$(stringexpression)
This function converts all lower case characters in
stringexpression to upper case and returns as new
string.
VAL(stringexpression)
This function returns the numeric value of string
stringexpression.
WRITE #filenumber,expression list
Write is performs the same way as Print with these
exceptions: 1) Commas are inserted between all items;
2) Strings are bracketed by quotation marks.
BasicBasic does not support using the Write statement to
display on the screen.
24
BasicBasic is copyright (c) 1992 by Mark Davidsaver
WINDOWS AND FONTS
-------------------------------------------------------
The following discussion is current for Windows Version
3.1. The concepts discussed are applicable for Version
3.0, however, font file names are different for that
version.
BasicBasic selects the OEM Fixed font closest in size to
the system font size used in menus, buttons, etc. If you
desire a different font size when running a BasicBasic
program you can select from available fonts in the System
Menu. You may also mark a given font size to be the new
default for that program.
Depending on how you configured your system there may be
only one OEM font installed. Windows 3.1 comes with an
assortment of OEM fonts. The file DOSAPP.FON contains the
fonts used by Windows to run DOS in a window and are good
for use with BasicBasic. If this file is not in you
windows system directory (e.g. WINDOWS\SYSTEM) then your
can copy it from your distributions disks and then use the
Control Panel Fonts accessory to install them (These fonts
have the name 'MS-DOS CP 437').
IMPORTANT INFORMATION FOR 386 ENHANCED MODE: If you use
the MS-DOS prompt in 386 Enhanced mode you will need to
make a change in your SYSTEM.INI file to use multiple size
fonts in BasicBasic. As mentioned previously Windows does
not normally permanently install the fonts from
DOSAPP.FON. As was indicated you can do this from the
Control Panel Fonts accessory. HOWEVER, you will find
that each time you EXIT the MS-DOS prompt these fonts will
be REMOVED from the system. This is because Windows does
not expect these fonts to be present and there is a
control line in SYSTEM.INI which explicitly tells it to
load and unload them when running the MS-DOS prompt. Once
you have installed these fonts you can keep Windows from
un-installing them by removing the following line from the
[386Enh] section of SYSTEM.INI:
WOAFONT=DOSAPP.FON
FONTS AND BUTTONS: This discussion applies only to buttons
which are defined by the user to be one line high. If you
select a font smaller than the system font for use in a
BasicBasic program the text in any buttons you have would
be too crowded in the button space available. BasicBasic
corrects this problem in one of two ways. 1) If you
system font is only slightly larger than the font selected
in BasicBasic then any text in the buttons will be made
all upper case so no 'descenders' will be outside the
25
BasicBasic is copyright (c) 1992 by Mark Davidsaver
button area. 2) If the system font is quite a bit larger
than the selected font then BasicBasic will not use the
standard Windows button design. Instead it will draw a
'simplified' button which can hold the small text of the
font.
26
BasicBasic is copyright (c) 1992 by Mark Davidsaver
PROGRAMMING BUTTONS
-------------------------------------------------------
Buttons can be used in either DOS or Windows. Buttons do
not require the presence of a mouse. Here is an example
of a valid create button command:
CBUTTON "EXIT",1068,0,"Push",0,1,1,8,1,7,4
Here is a description of each parameter:
EXIT - This is the name displayed in the button
1068 - This is keycode for F10 (User can either
use mouse to push button or press F10.
0 - Reserved
Push - Type of button. 'Radio' is the other type.
0 - Reserved
1 - Left position
1 - Y position
8 - x size (in characters)
1 - y size (in characters)
7 - foreground color (In Windows only used for Radio
buttons).
4 - background color (In Windows only used for Radio
buttons).
In DOS a push button will have text centered and if the
defined text size is at least 2 characters smaller than
the button size a line will be drawn around the outside.
Remember that if a mouse is going to be used it MUST be
turned on with the MOUSEON function before it can be used
to press a button.
Here is an example of a small program which uses buttons:
A=MOUSEON
IF A=-1 THEN
CBUTTON "EXIT",1068,0,"PUSH",0,70,1,8,1,0,0
ELSE
CBUTTON "F10-Exit",1068,0,"PUSH",0,70,1,10,1,0,0
END IF
INPUT Z
27
BasicBasic is copyright (c) 1992 by Mark Davidsaver
a$=INKEY$
PRINT LEN(A$)
This program displays different text in the button
depending on whether a mouse is present or not.
Assuming there is a mouse this program will end under
the following conditions:
- User presses EXIT button with mouse
- User presses F10 on keyboard
- User presses ENTER key on keyboard.
In the first two cases the print will show a length of 2
for the length of A$ since the button keycode will be
returned on the next INKEY$ after the INPUT is
terminated.
Once you have created a button you are responsible for NOT
writing anything to that area of the screen. If you do
the button will be erased. If you are using buttons and
scrolling text on the screen make sure you use the
SCROLLAREA command to protect the button area of the
screen.
INVISIBLE buttons can be particularly useful. An
invisible button does not appear on the screen, but a
button push inside it's defined area will return it's
keycode just as if it were. This allows you to create
your own special color buttons or input areas. For
instance you could have a series of INPUT statements in a
program and each could be defined as an invisible button.
When the user clicked on that input area you would get a
unique keycode which would direct your program to the
section of code which handles that input.
Since buttons end INPUT commands you can also use
invisible buttons to define any keys you want to end INPUT
commands (e.g. UP ARROW or DOWN ARROW).
28
BasicBasic is copyright (c) 1992 by Mark Davidsaver
PROGRAMMING MENUS
-------------------------------------------------------
Menus are not supported in DOS. Menu commands are ignored
when running under DOS.
Menus support in BasicBasic is much like button support.
When the user selects a menu item a defined keycode is
returned to the Basic program. Menu keycodes are returned
only using the INKEY$ function call. However, if the user
selects a menu item while the program is waiting for input
in an INPUT command the input command will be terminated
just as if the user had pressed Enter. Then on the next
INKEY$ call the keycode for the menu item will be
returned.
KEYCODES: Just as in buttons keycodes can be regular or
extend keys. Extended keys are indicated by adding 1000
to the regular keycode. F10 would be 1068. See the
Appendix 'Keyboard codes' for a complete list.
The mouse must be enable with the MOUSEON command before
any menu items will be recognized.
Here is an example of a simple Windows program which
utilizes menus.
y=mouseon
mainmenu "Color","","","","",""
addsubmenu 1,"Black",1059
addsubmenu 1,"White",1061
backcolor=0
menuitemgray 1059
50
cls
color 1,backcolor
locate 10,30
print "Sample text..";
100
a$=inkey$
if a$="" then goto 100
if len(a$)=1 then goto 100
if right$(a$,1)=chr$(59)
menuitemon 1060
menuitemgray 1059
backcolor=7
goto 50
elseif right$(a$,1)=chr$(60)
menuitemon 1059
menuitemgray 1060
backcolor=0
goto 50
end if
29
BasicBasic is copyright (c) 1992 by Mark Davidsaver
goto 100
This program defines one menu and then adds two items to
it. These menu items allow the user to clear the screen
to either black or white. The program disables the menu
item for whatever color the screen currently is.
The menu could be define in the following way also.
mainmenu "&Color","","","","",""
addsubmenu 1,"&Black",1059
addsubmenu 1,"&White",1061
The apersand (&) allows you to define which character in
the menu will be underlined which allows the user to
select this item by pressing the ALT key and this letter.
This IS NOT the keycode which will be returned to your
program. This keycode will always be the one given as the
last parameter of the addsubmenu command.
We could also define the menu like this:
mainmenu "&Color","","","","",""
addsubmenu 1,"&Black",1059
addsubmenu 1,"",0
addsubmenu 1,"&White",1061
The 3rd line (addsubmenu 1,"",0) creates a line seperator
in the menu bar. It can not be selected by the user.
30
BasicBasic is copyright (c) 1992 by Mark Davidsaver
COMMUNICATIONS PROGRAMMING
-------------------------------------------------------
Here is a brief example of using a communications port.
rem
rem open communications port
rem
OPEN "COM1: 2400,N,8" FOR RANDOM AS #1 LEN=2048
100
rem
rem get input from communications port
rem
t = LOC(1)
IF t > 0 THEN
a$=input$(t,1)
if len(a$)>0 then
rem come here to display received characters
PRINT a$;
ELSE
rem come here if some kind of comm error that kept
rem us from getting the waiting character.
end if
END IF
rem
rem get input from keyboard
rem
b$ = INKEY$
IF b$ <> "" THEN
PRINT #1, b$;
END IF
GOTO 100
31
BasicBasic is copyright (c) 1992 by Mark Davidsaver
CHAINING AND COMMON
-------------------------------------------------------
Here are examples of two programs, CHAIN1 and CHAIN2,
which pass variables back and forth in common.
CHAIN1
common a,b,c,d$(),c()
if a=0 then
cls
a=1
dim d$(10)
dim c(20)
d$(5)="This is d$(5)"
end if
print "press any key to go to chain 2"
100
a$=inkey$
if a$="" then goto 100
chain "chain2.exe"
CHAIN2
common a,b,c,d$(),c()
b=b+1
print "this is chain 2"
print "b=";b;
print d$(5)
input z
chain "chain1.exe"
32
BasicBasic is copyright (c) 1992 by Mark Davidsaver
ERROR MESSAGES
-------------------------------------------------------
Compile errors will give a description of the problem and
display the line where the error occurred.
Runtime errors are divided into two classes. Fatal errors
always cause execution of the program to cease.
Recoverable errors cause program execution to cease if
SETERRLEVEL is 7, overwise execution continues and the
error number is placed in the system variable ERR.
SETERRLEVEL 7 is the default.
When runtime errors are displayed they are accompanied by
a runtime address. The compiler will optionally output a
list of runtime addresses for each statement. These
addresses will be contained in a file with the same name
as the source file and an extension of .TMP. In Windows
you select debug output by selecting the Debug Output box.
In the DOS version of the compiler you select debug output
by putting a /D in the command line (e.g. BB MYPROG /D).
Fatal Errors:
error number description
------------ -----------
503 READ is attempting to read wrong kind
of data.
501
...
522 Internal runtime errors.
523 Wrong number of array elements or
array not dimensioned.
524 Out of free space.
525 Out of string space.
Recoverable Errors:
1000 Error attempting to open file
1001 Attempt to read past end of file
1002 File not open
1003 File read error (probably hardware)
1004 ASC function on empty string
1005 Divide by zero
1006 Out of data during READ
1007 File already open
1008 No available file control block
1009 Error attempting to open file
1010 File mode error on read
1011 File mode error on write
1012 Bad file number
1013 Path not found
33
BasicBasic is copyright (c) 1992 by Mark Davidsaver
1014 RMDIR error
1015 MKDIR error
1016 KILL error
1017 FILE BUFFER ERROR
1018 INVALID FIELD DATA
1019 FIELD OVERFLOW
1020 FILE ERROR
1021 COMMUNICATIONS OPEN ERROR
1022 CREATE BUTTON ERROR
34
BasicBasic is copyright (c) 1992 by Mark Davidsaver
KEYBOARD CODES
-------------------------------------------------------
The following table shows the key codes returned by the
INKEY$ function. These key codes are returned as 1 byte.
KEY DECIMAL KEY DECIMAL KEY DECIMAL
KEY CODE KEY CODE KEY CODE
ESC 27 BKSP 8
1 49 ! 33 TAB 9
2 50 @ 64 ENTER 13
3 51 # 35 SPACE 32
4 52 $ 36
5 53 % 37
6 54 ^ 94
7 55 & 38
8 56 * 42
9 57 ( 40
0 48 ) 41
- 45 _ 95
= 61 + 43
KEY DECIMAL KEY DECIMAL KEY DECIMAL
KEY CODE KEY CODE KEY CODE
A 65 a 97
B 66 b 98
C 67 c 99
D 68 d 100
E 69 e 101
F 70 f 102
G 71 g 103
H 72 h 104
I 73 i 105
J 74 j 106
K 75 k 107
L 76 l 108
M 77 m 109
N 78 n 110
O 79 o 111
P 80 p 112
Q 81 q 113
R 82 r 114
S 83 s 115
T 84 t 116
U 85 u 117
V 86 v 118
W 87 w 119
X 88 x 120
Y 89 y 121
Z 90 z 122
35
BasicBasic is copyright (c) 1992 by Mark Davidsaver
The following table shows the extended key codes returned
by the INKEY$ function. These key codes are returned as 2
characters. In this case the first character will be 0.
KEY DECIMAL
KEY CODE
---- ------
F1 0 59
F2 0 60
F3 0 61
F4 0 62
F5 0 63
F6 0 64
F7 0 65
F8 0 66
F9 0 67
F10 0 68
CTRL-F1 0 94
CTRL-F2 0 95
CTRL-F3 0 96
CTRL-F4 0 97
CTRL-F5 0 98
CTRL-F6 0 99
CTRL-F7 0 100
CTRL-F8 0 101
CTRL-F9 0 102
CTRL-F10 0 103
SHIFT-F1 0 84
SHIFT-F2 0 85
SHIFT-F3 0 86
SHIFT-F4 0 87
SHIFT-F5 0 88
SHIFT-F6 0 89
SHIFT-F7 0 90
SHIFT-F8 0 91
SHIFT-F9 0 92
SHIFT-F10 0 93
HOME 0 71
UP ARROW 0 72
PGUP 0 73
LEFT ARROW 0 75
RIGHT ARR 0 77
END 0 79
DOWN ARROW 0 80
PGDN 0 81
INS 0 82
DEL 0 83
CTRL-HOME 0 119
CTRL-PGUP 0 132
CTRL-LEFT 0 115
CTRL-RIGHT 0 116
CTRL-END 0 117
CTRL-PGDN 0 118
36
BasicBasic is copyright (c) 1992 by Mark Davidsaver
Windows is a registered trademark of Microsoft
Corporation.
37